<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>019-面向对象高级-继承二.html</title>
</head>
<body>
	
</body>
<script>
	function Person(name,age){
		this.name = name;
		this.age = age;
	}
	Person.prototype.showName = function(){
		console.log("I am "+ this.name);
	}
	Object.defineProperty(Person.prototype,"showAge",{
		value:function(){
			console.log("I am "+ this.age + 'years old');
		},
		enumerable:true
	})
	
	Person.prototype.LEGS = 2;
	
	function Student(name,age,major){
		Person.call(this,name,age);
		this.major = major;
	}


	for(var attr in Person.prototype){
		Student.prototype[attr] = Person.prototype[attr];
	}

	Student.prototype.showMajor = function(){
		console.log("I am from "+this.major);
	}

	var s1 = new Student("chris",18,"COM");
		console.log(s1);
		s1.showName();
		s1.showMajor();
		s1.showAge();


	var p1 = new Person("vincent",24);
		p1.showName();
		// p1.showMajor();
		p1.showAge();
		console.log(p1);
	</script>
</html>